using System;
using System.Collections.Generic;
using System.Text;
using FinanceStats.Entities;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using FinanceStats.Common;
using System.Data;

namespace FinanceStats.DAL
{
    public static class OutcomeDayDAO
    {
        private static string getTotal = "SELECT ISNULL(SUM(AMOUNT), 0) AS TOTALDAY FROM ACS.DBO.USEROUTCOME WHERE DATE = '{0}'";

        public static decimal GetDayTotal(DateTime date)
        {
            decimal total = 0;
            SqlDatabase db = new SqlDatabase(AppSettingsHelper.GetWebConfigValue(Constants.ACSConnectionString));
            string sql = String.Format(getTotal, date.Date);
            total = (decimal)db.ExecuteScalar(CommandType.Text, sql);
            return total;
        }
    }
}
